using System;
using System.Text;

namespace Microsoft.Modeling.StoryboardDesigner
{
    public partial class StoryboardElement
    {
        string title;

        private static string ConvertNameToTitle(string name)
        {
            if(name == null)
                return string.Empty;

            StringBuilder sb = new StringBuilder();
            char last = 'A';

            foreach(char ch in name)
            {
                if(Char.IsUpper(ch))
                {
                    if(Char.IsLower(last))
                    {
                        sb.Append(' ');
                    }
                }
                else if(Char.IsDigit(ch))
                {
                    if(!Char.IsDigit(last))
                    {
                        sb.Append(' ');
                    }
                }
                sb.Append(ch);
                last = ch;
            }

            return sb.ToString();
        }

        public string GetTitleValue()
        {
            if(this.title == null || this.title.Length == 0)
            {
                return ConvertNameToTitle(this.Name);
            }
            else
            {
                return title;
            }
        }

        public void SetTitleValue(string value)
        {
            this.title = value;
        }

        public string GetTypeValue()
        {
            return this.GetDomainClass().DisplayName;
        }
    }
}